package com.soft.javase.day07.loginexception;

import javax.swing.*;

/**
 * @author yzg
 * @desc TODO
 * @date 2025/4/27
 */
class UserService {
    public static boolean login(Long id, String password) throws LoginException {
        if (id == null || password == null || password.equals("")) {
            throw new LoginException("账户或密码不能为空");
        }

        if (id.equals(111L) && password.equals("123456")) {
            JOptionPane.showMessageDialog(null, "登陆成功", "通知", JOptionPane.INFORMATION_MESSAGE);
            return true;
        }

        throw new LoginException("账户与密码不匹配");
    }

    public static void main(String[] args) {
        try {
            System.out.println(login(111L, "123456"));
        } catch (LoginException e) {
            e.printStackTrace();
        }
    }
}
